package com.heo.music.player.controller;


import com.heo.music.player.auth.NeedLogin;
import com.heo.music.player.dto.input.MusicCommentInput;
import com.heo.music.player.dto.output.MusicCommentOutput;
import com.heo.music.player.dto.output.PageOutput;
import com.heo.music.player.dto.query.PageQuery;
import com.heo.music.player.service.MusicCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Api(tags = "音乐评论接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1")
public class MusicCommentController {

    private final MusicCommentService musicCommentService;

    @ApiOperation("获取音乐评论")
    @GetMapping("/musicInfo/{musicId}/comment")
    public PageOutput<MusicCommentOutput> findAllMusicComment(@PathVariable Integer musicId, @Valid PageQuery query) {
        return musicCommentService.findAllMusicComment(musicId, query);
    }

    @ApiOperation("发布音乐评论")
    @PostMapping("/musicInfo/{musicId}/comment")
    @NeedLogin
    public MusicCommentOutput createMusicComment(@PathVariable Integer musicId, @Valid @RequestBody MusicCommentInput input) {
        return musicCommentService.createMusicComment(musicId, input);
    }

}
